package relu.R.landscape;

import java.util.ArrayList;

import jfm.mou.FarmerMOU;

/** Extends the geographic location distribution to allow duplicate sets of farms to be compared under different scenarios */
public class DualGeographicLocationDistribution extends
		GeographicLocationDistribution {
	private ArrayList<LSFarm> baseFarms=new ArrayList<LSFarm>();
	private ArrayList<LSFarm> treatmentFarms=new ArrayList<LSFarm>();
	
	public ArrayList<LSFarm> getBaseFarms(){
		return baseFarms;
	}
	public ArrayList<LSFarm> getTreatedFarms(){
		return baseFarms;
	}
	
	
	
	/** Creates and clones representative farms */
	public void createRepresentativeFarms(int nFarms,NonSpatialLandscape ls,NonSpatialLandscape lsa){
		double[] areas=sampleAreas(nFarms);
		String[] mouFiles=sampleMOUs(nFarms);
		String[] xmlFiles=sampleXMLs(nFarms);
		double[] soils = sampleSoils(nFarms);
		for(int i=0;i<nFarms;i++){
			FarmerMOU fmou = FarmerMOU.fromXML(mouFiles[i]);
			LSFarm theFarm = LSFarm.fromXML(xmlFiles[i], ls, null, areas[i]);
			theFarm.applyMOUToFarm(fmou);
			theFarm.setLocationInfo(soils[i], rainFall);
			baseFarms.add(theFarm);
			
			LSFarm theAlternateFarm = LSFarm.fromXML(xmlFiles[i], lsa, null, areas[i]);
			theAlternateFarm.applyMOUToFarm(fmou);
			theAlternateFarm.setLocationInfo(soils[i], rainFall);
			treatmentFarms.add(theAlternateFarm);
		//	System.out.println("Adding farm "+xmlFiles[i]+" "+areas[i]+" "+soils[i]+" "+rainFall);
		}
	}
		
	
}
